﻿#include "login.h"
#include "ui_login.h"
#include"mainscene.h"
#include<QMessageBox>
#include<QPainter>
#include<QPixmap>
#include<QPainterPath>

Login::Login(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Login)
{
    ui->setupUi(this);

    //登录页面设置
    setFixedSize(536,414);
    ui->lineEdit->setText("admin");
    ui->lineEdit_2->setText("1234");
    this->setWindowTitle(QStringLiteral("登录界面"));

    //返回登录按钮设置
    connect(pg_Mainscene,&MainScene::backLogin,this,&Login::thisShow);


}


Login::~Login()
{
    delete ui;
}

/*************************************************

  Description:    登录按钮槽函数
  return:         void
  Called By:
  Input:          无
  Auther:         林锦涛
  Time:           2021-1-23 14:31:48

*************************************************/
void Login::on_btn_login_clicked()
{
    int psw;
    QString str;
    str = ui->lineEdit->text();
    psw = ui->lineEdit_2->text().toInt();

    if (str == "admin" && psw == 1234){
        QTimer::singleShot(500,this,[=](){

            pg_Mainscene->setGeometry(this->geometry());
            this->hide();
            pg_Mainscene->show();

        });

    }
    else
    {
        QMessageBox::information(this,"Error",QStringLiteral("账号或者密码错误"));
    }

}

/*************************************************

  Description:    取消按钮槽函数
  return:         void
  Called By:
  Input:          无
  Auther:         林锦涛
  Time:           2021-1-23 14:31:48

*************************************************/
void Login::on_btn_cancel_clicked()
{
    QTimer::singleShot(500,this,[=](){
        this->close();
    });

}


/*************************************************

  Description:    返回登陆界面槽函数
  return:         void
  Called By:
  Input:          无
  Auther:         林锦涛
  Time:           2021-1-23 14:31:48

*************************************************/
void Login::thisShow()
{
    QTimer::singleShot(500,this,[=](){


        this->setGeometry(pg_Mainscene->geometry());
        pg_Mainscene->hide();
        this->show();

    });

}

////重写绘图事件
//void Login::paintEvent(QPaintEvent *)
//{


//}
